package Demo1.a03demo3;

public class Test1 {
    public static void main(String[] args) {
        int num = 123;
        String binaryString = toBinaryString(num);
        System.out.println(binaryString);
        String binaryString1 = Integer.toBinaryString(num);
        System.out.println(binaryString1);

    }

    public static String toBinaryString(int num) {
        StringBuilder sb = new StringBuilder();
        while (num != 0) {
            int remaindar = num % 2;
            sb.insert(0, remaindar);
            num = num / 2;
        }
        return sb.toString();
    }
}








